package com.lefull.lefullbase.utils.helper;

import android.content.Context;
import android.content.SharedPreferences;

import com.lefull.lefullbase.base.LeFullBaseModule;

import java.util.Set;

public class P {

    public static final String PREFERENCESNAME = "rsung";
    public static final int PREFERENCESMODE_PRIVATE = Context.MODE_PRIVATE;
    public static final int PREFERENCESMODE_PUBLIC = Context.MODE_MULTI_PROCESS;
    public static final String TOKEN = "token"; // 安全校验码
    public static final String SECRET = "secret";//秘钥
    public static final String UPDATEEXPIRESTIME = "update_time";//非强制更新下次提示的过期时间
    public static final String RONGTOKEN = "rong_token";//融云的token
    public static final String KEY = "key";
    public static final String NOTWELCOME = "notwelcome"; // 是否第一次打开App
    public static final String WELCOME = "welcome"; // 是否为第一次登录
    public static final String DEVICETOKEN = "device_token"; //推送的设备型号
    public static final String STATETEXT = "state_text"; //保存动态文字
    public static final String STATEIMG = "state_img"; //保存动态图片
    public static final String LONGITUDE = "longitude"; //经度
    public static final String LATITUDE = "latitude"; //纬度
    //    public static final String UNTILTIME = "untiltime"; //连续5次输入安全码错误后的时间
    public static final String PAYMONEY = "paymoney"; //付款的金额
    public static final String PAYTYPE = "paytype"; //1 活动报名 2商品购买 3电费充值 4委托转租支付 5分期账单支付 6杂费充值  7预约保洁
    //    配置信息
    public static final String QINIUURLHEADER = "qiniuheder"; //七牛云服务器连接地址
    public static final String NICKNAME = "nickname";
    //个人信息
    public static final String AGE = "age";
    public static final String GENDER = "gender";
    public static final String PROVINCEID = "province_id";
    public static final String LOVEID = "love_status_configuration_id";
    public static final String ISVIP = "is_vip";
    public static final String HEADIMG = "head_img";
    public static final String HEADPATH = "head_path";
    public static final String SINGNATURE = "signature";
    public static final String JOBID = "job_id";
    public static final String JOBNAME = "job_name";
    public static final String PROVINCE = "province";
    public static final String HOBBYID = "hobby_id";
    public static final String HOBBYNAME = "hobby_name";
    public static final String APARMENTID = "apartment_id";
    public static final String ISSYSTEM = "is_system";
    public static final String APARMENTNAME = "apartment_name";
    public static final String TAG = "tag";
    public static final String APARTMENTNAME = "apartment_name";
    public static final String TENANTID = "tenant_id";
    public static final String IDCARD = "idcard";
    public static final String PHONE = "phone";
    public static final String ROOMNUMBER = "roomnumber";
    public static final String TENANTAUTHORITY = "tenant_authority";
    //支付
    public static final String ISALIPAY = "is_alipay"; //是否安装支付宝
    public static final String ISWECHAT = "is_wechat"; //是否安装微信
    //定位的城市
    public static final String CITYID = "city_id";
    public static final String CITYNAME = "city_name";
    private static SharedPreferences preferences = LeFullBaseModule.getInstance().getApplication().getSharedPreferences(PREFERENCESNAME, PREFERENCESMODE_PRIVATE);
    private static SharedPreferences publicPreferences = LeFullBaseModule.getInstance().getApplication().getSharedPreferences(PREFERENCESNAME,
            PREFERENCESMODE_PUBLIC);

    public static void saveString(String key, String value) {
        try {
            preferences.edit().putString(key, value).commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getString(String key) {
        return preferences.getString(key, null);
    }

    public static void saveInt(String key, int value) {
        preferences.edit().putInt(key, value).commit();
    }

    public static int getInt(String key) {
        return preferences.getInt(key, 0);
    }

    public static void saveLong(String key, long value) {
        preferences.edit().putLong(key, value).commit();
    }

    public static long getLong(String key) {
        return preferences.getLong(key, 0);
    }

    public static void saveFloat(String key, float value) {
        preferences.edit().putFloat(key, value).commit();
    }

    public static float getFloat(String key) {
        return preferences.getFloat(key, 0);
    }

    public static void saveBool(String key, boolean value) {
        preferences.edit().putBoolean(key, value).commit();
    }


    public static boolean getBool(String key) {
        return preferences.getBoolean(key, false);
    }

    public static void savePublicBool(String key, boolean value) {
        publicPreferences.edit().putBoolean(key, value).commit();
    }

    public static boolean getPublicBool(String key) {
        return publicPreferences.getBoolean(key, false);
    }

    public static String getPublicString(String key) {
        return publicPreferences.getString(key, null);
    }

    public static void savePublicString(Context context, String key, String value) {
        try {
            publicPreferences.edit().putString(key, value).commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public static void saveList(String key, Set<String> set) {
        preferences.edit().putStringSet(key, set).commit();
    }

    public static Set<String> getList(String key) {
        return preferences.getStringSet(key, null);
    }

    public static void clearLefullData() {
        preferences.edit().clear().commit();
    }
}
